-- spell_bonus3
-- created by shuzy
-- 每前进N层时，获得1张特定魔法卷轴

return {
    apply = function(prop, baseValue)
        return baseValue + prop[3];
    end,

    -- 进入下一层触发
    trigger = function(who, prop, arg)
        if who.type ~= OBJECT_TYPE_USER then
            return false;
        end

        -- 客户端此时还在前一层，需要+1计算
        local floor = DungeonM.currentLayer() + 1;
        -- 卷轴的数量和阶位
        local count = 1;
        local spell = tonumber(prop[2]);
        local bonusFloor = tonumber(prop[3]);

        -- 不在对应楼层不给
        if floor % bonusFloor ~= 0 then
            return false;
        end

        BonusM.doBonus({ 1, spell, count, }, "spell_bonus3");

        return true;
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        -- 数量
        desc = string.gsub(desc, "{1}", prop[3]);

        -- 物品名称
        desc = string.gsub(desc, "{0}", ItemM.query(prop[2],"name"));

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};